package com.example.mybatisplus.web.controller;

import com.example.mybatisplus.mapper.AdminMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.mybatisplus.common.JsonResponse;
import com.example.mybatisplus.service.AdminService;
import com.example.mybatisplus.model.domain.Admin;



@Controller
@RequestMapping("/api/admin")
public class AdminController {


    @Autowired
    private AdminService adminService;


    @RequestMapping("xx")
    @ResponseBody
    public Admin hh(){
        Admin admin = adminService.getByIdMy(88);
        return admin;
    }
//发请求的同时发参数
    //1.get典型传参  直接用参数列表接 方法名与键名一致
    @GetMapping("getById")
    @ResponseBody
    public Admin qq(Long id){
        return adminService.getById(id);
    }
    //get  用对象接 要求对象名和前端传的键名一致

    @GetMapping("getByIdhhh")
    @ResponseBody
    public Admin qq1(Admin admin){
        return adminService.getById(admin.getId());

    }

    @GetMapping("login")
    @ResponseBody
    public JsonResponse login(Admin admin){
        Admin login= adminService.login(admin);
        return JsonResponse.success(login);
    }

}

